/**
 * create by young (young2f@outlook.com) on 2020/9/12
 */


'use strict';
import React from 'react';
import {connect} from 'dva/index';
import {DatePicker, Form, Select} from 'antd';
import styles from '../index.less';
import FormBase from '../../components/Base/FormBase';
import moment from 'moment';
import 'moment/locale/zh-cn';
import DirTree from "../../components/DirTree";
import PaymentReviewDataFace from "./dataFace/PaymentReviewDataFace";
import PaymentDataFaceMainMaterial from "./dataFace/material/PaymentDataFaceMainMaterial";
import PaymentDataFaceAuxMaterial from "./dataFace/material/PaymentDataFaceAuxMaterial";
import PaymentReviewDataFaceMainMaterial from "./dataFace/material/PaymentReviewDataFaceMainMaterial";
import PaymentReviewDataFaceAuxMaterial from "./dataFace/material/PaymentReviewDataFaceAuxMaterial";

moment.locale('zh-cn');
const {RangePicker} = DatePicker;
const _ = require('lodash');

const table = 'payment';
const title = '付款申请审核';
const {Option} = Select;
@Form.create()
@connect(({
            user,
            global,
            dynamicLabel,
            procure,
            finance
          }) => ({...user, ...global, ...procure, ...finance, ...dynamicLabel}))
export default class PaymentReviewTree extends FormBase {
  constructor(props) {
    super(props);
    this.state = {};
  }


  componentDidMount() {
    this.setState({});

  }

  onTreeNodeSelected = (node) => {
    if (!node) return;
    this.state.treeNode = node;
    this.componentDidMount();
  };
//todo
  onTreeDelete = (_id, result) => {

  };

  dataPage() {
    const {treeNode = {}} = this.state;
    const {treeId, name, mark} = treeNode;

    // if (mark === 'TRE-PROCURE-MAIN') {
    //   return <ProcureMainDataFace
    //     treeId={treeId}
    //     title={name}
    //     isPayReview={true}
    //     callback={() => this.componentDidMount()}
    //   ></ProcureMainDataFace>;
    // }
    //
    // if (mark === 'TRE-PROCURE-AUX') {
    //   return <ProcureAuxDataFace
    //     treeId={treeId}
    //     title={name}
    //     isPayReview={true}
    //     callback={() => this.componentDidMount()}
    //   ></ProcureAuxDataFace>;
    // }
    if (mark === '采购主材付款申请') {
      return <PaymentReviewDataFaceMainMaterial
        // treeId={treeId}
        // treeName={name}
        treeNode={treeNode}
        callback={() => this.componentDidMount()}
      ></PaymentReviewDataFaceMainMaterial>
    }
    if (mark === '采购辅材付款申请') {
      return <PaymentReviewDataFaceAuxMaterial
        // treeId={treeId}
        // treeName={name}
        treeNode={treeNode}
        callback={() => this.componentDidMount()}
      ></PaymentReviewDataFaceAuxMaterial>
    }
    return <PaymentReviewDataFace
      treeId={treeId}
      treeName={name}
      isPayReview={true}
      callback={() => this.componentDidMount()}
    ></PaymentReviewDataFace>;
  }

  render() {
    const {dispatch, _notify, expandedKeys} = this.props;

    return (
      <Form className={styles.content}>
        <DirTree
          width={"22%"}
          disableEdit={false}
          codeEdited={true}
          table={table}
          dispatch={dispatch}
          onTreeDelete={this.onTreeDelete}
          onTreeNodeSelected={this.onTreeNodeSelected}
          expandedKeys={expandedKeys}
          defaultExpandAll={true}
          title={title}
        > {this.dataPage()}</DirTree>
      </Form>
    );
  }
}
